<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>收货地址</title>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        body {
            background-image: url(images/be.jpg);
            background-size: cover;
        }

        #div1 {
            width: 300px;
            height: 500px;
            margin: 0 auto;
            margin-top: 150px;
        }

        input {
            border-radius: 10px;
        }

        form {
            font-size: 17px;
            color: #777;
        }

        p {
            margin-left: 5px;
        }

        #div1 button {
            width: 100px;
            margin: 0 auto;
            margin-bottom: 20px;
            background: #777;
            color: #ff0;
        }

        #div1 form article {
            position: relative;
        }

        #div2,
        #div3 {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-70%, -100%);
            display: none;
        }

        #div2 ul{
            list-style: none;
        }
        #div2 ul button{
            width: 80px;
            height: 50px;
            background: #00f;
            color: #f00;
        }
        #div3 p {
            font-size: 20px;
        }

        #div3 p span {
            font-size: 30px;
            color: #f00;
        }
        #div3 ul li{
            list-style: none;
        }
    </style>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        function submit() {
            var input1 = document.getElementsByTagName("input")[0]
            var input2 = document.getElementsByTagName("input")[1]
            var input3 = document.getElementsByTagName("input")[2]
            // document.getElementsByTagName("button")[0].onclick = function () {
                var reg = /[\u4E00-\u9FA5]/
                if (reg.test(input1.value) == false) {
                    alert("填写姓名格式错误")
                }
                if (isNaN(input2.value) || (input1.value) == "") {
                    alert("联系方式格式错误")
                }
                var reg = /[\u4E00-\u9FA5]/
                if (reg.test(input3.value) == false) {
                    alert("收货地址格式错误")
                }


                if (reg.test(input1.value) == true && isNaN(input2.value) == false && reg.test(input3.value) == true) {
                    alert("提交成功")
                    document.getElementById("div1").style.display = "none"
                    document.getElementById("div2").style.display = "block"
                    var ul = document.querySelector("ul")
                    var li = document.createElement("li")
                    li.innerHTML += "<p>" + "姓名：" + input1.value + "</p><br><br><p>" + "联系方式：" + input2.value + "</p><br><br><p>" + "收货地址：" + input3.value + "</p><br><br><button id='right' onclick='right()'>确认<tton>"
                    ul.appendChild(li)
                } else {
                    alert("提交error")
                    document.getElementById("div1").style.display = "block"
                }

            }
        $(function () {
            $("button").css("text-align", "center")
            $("button").eq(1).click(function () {
                $("input").val("")
            })
        })
       
        function right(){
            document.querySelector("#div2").style.display = "none"
            document.querySelector("#div3").style.display = "block"
            var input1 = document.getElementsByTagName("input")[0]
            var ul = document.querySelector("#div3").querySelector("ul")
            var li1 = document.createElement("li")
            li1.innerHTML = "<p><span>"+input1.value+"</span>先生/女士你好，请耐心等待我们会尽快送达 </p>"
            ul.appendChild(li1)
            
        }
    </script>
</head>

<body>
    <div id="div1">
        <form action="" id="myform"></form>
        姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<input type="text" form="myform" maxlength="4"><br><br>
        联系方式：<input type="text" maxlength="11" form="myform" placeholder="请输入11位数字"><br><br>
        具体地址：<input type="text" placeholder="如：xxx街道xxx号" form="myform" ><br><br>
        <article>备注：</article></span><textarea name="" id="" cols="30" rows="10" maxlength="100" form="myform" ></textarea>
        <p>提示：备注最多输入100个字符</p><br><br>
        <button onclick="submit()">提交</button>
        <button onclick="reset()">重置</button>
    </div>
    <div id="div2">
        <ul></ul>
    </div>
    <div id="div3">
        <ul></ul>
    </div>
</body>

</html>